package net.chathu.airgw.packets.chat 
{
	import net.chathu.airgw.Config;
	import net.chathu.airgw.model.Room;
	import net.chathu.airgw.model.User;
	import net.chathu.airgw.packets.gw.serverpackets.PartPacket;
	/**
	 * ...
	 * @author ze
	 */
	public class UnsubRooms extends ChatPacket 
	{
		
		public function UnsubRooms() 
		{
			
		}
		
		override public function execute():void
		{
			//kileptel egy szobabol
			var posA:int=(data[1]).indexOf('/',0) +1;
			var posB:int=(data[1]).indexOf('/', 7) ;
			var roomId:int = parseInt(data[1].substring(posA, posB));
			
			var room:Room = sessionData.chatData.rooms.getRoom(roomId)
			
			if (room) {
				sessionData.chatData.removeJoinedRoomInfo(roomId);
				//var yourUser:User = sessionData.chatData.users.getUser(sessionData.chatData.userId);
				sendToClient(new PartPacket(sessionData.yourHost,room.name));
			} else {
				trace("Missing room! id: " + roomId + " (unsubrooms)");
			}
		}
		
	}

}